package com.shf.compoment
{
	import com.shf.event.PageEvent;
	
	import mx.controls.DataGrid;
	
	[Event(name="pageClick", type="com.shf.event.PageEvent")]
	public class PaginationDataGrid extends DataGrid
	{
		public function PaginationDataGrid()
		{
		}
		
		private var pagination:Pagination;
		
		private var paginationHeight:Number = 30;
		
		private var _pageInfo:PageInfo;
		
		public function set pageInfo(value:PageInfo):void{
			pagination.page = this._pageInfo = value;
		}
		
		override protected function createChildren():void{
			super.createChildren();
			if(!pagination){
				pagination = new Pagination();
				pagination.addEventListener(PageEvent.PAGE_CLICK,function(event:PageEvent):void{
					dispatchEvent(e);
				});
				pagination.visible = true;
				pagination.height = paginationHeight;
				pagination.percentWidth = 100;
				addChild(pagination);
			}
		}
		
		override protected function updateDisplayList(unscaledWidth:Number,
                                                  unscaledHeight:Number):void{
			super.updateDisplayList(unscaledWidth,unscaledHeight);
			pagination.setActualSize(unscaledWidth,30);
			pagination.move(listContent.x, listContent.y + listContent.height + 1);
		}
                                                  	
	}
}